<template>
  <div class="demo">
    <h1>学生名称:{{ name }}</h1>
    <h1 >学生性别:{{ sex }}</h1>
    <button @click="sendStudentName">点我发送学生姓名至School</button>
  </div>
</template>
<script>
import pubsub from 'pubsub-js'
export default {
  name: "Student",
  data() {
    return {
      name: "陈嘉兴",
      sex: "男",
    };
  },
  methods:{
     sendStudentName(){
      pubsub.publish('getStudentName',this.name)
     }
  }

};
</script>

<style >
.demo {
  background-color: brown;
}
</style>